<template>
  <div class="TabControl">
    <div class="tabItem" v-for="item,index in tabs" :key="index" :class="{active: index === currentIndex}"
         @click="tabItemClick(index)">
      <span>{{item}}</span>
    </div>
  </div>
</template>


<script>
    export default {
        name: "TabControl",
        props: {
            tabs: {
                type: Array,
                default() {
                    return []
                }
            }
        },
        data() {
            return {
                currentIndex: 0
            }
        },
        methods: {
            tabItemClick(index) {
                this.currentIndex=index
                this.$emit('changeGoods',index)
            }
        }
    }
</script>

<style scoped>
  .TabControl {
    display: flex;
    font-size: 15px;
    height: 40px;
    line-height: 40px;
    text-align: center;
  }

  .tabItem {
    flex: 1;
  }

  .tabItem span {
    padding: 6px;
  }

  .active {
    color: var(--color-high-text);
  }

  .active span {
    border-bottom: 3px solid var(--color-high-text);

  }
</style>
